Git Cheatsheet
Document Control
- Created: 23/05/06
- Last Updated: 23/05/06
Repo Status
# make sure to change location to the local git repo folder.
# Get git status update, this will tell you the status of commits, if you need to add un-tracked files, or push\pull updates.
git status
Stage files
# Add untracked file to git for commit (stage the file).
git add 'file name'
Un-stage files
# To unstage (remove) all files that have not been committed, -f = Force, -d = Directory
git reset -f -d
Commit staged files
# Commit staged changes to repo.
git commit -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
# Stage all changes and commit with comment, -a = all changes, -m = main branch.
git commit -a -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
Push changes to remote Repo
# Push your commited changes to remote repo.
Git push
Un-do recent commit
# To undo the most recent commit - A Git commit should not be reversed if you already pushed it to the remote repository.
git reset HEAD~1
Merge branch into main\master
# When you are ready to add your changes to the default branch, you merge the feature branch into it
git checkout 'default-branch'
git merge 'feature-branch'